package com.ruoyi.carShop.service.impl;


import com.ruoyi.carShop.domain.Statistics;
import com.ruoyi.carShop.domain.Withdrawal;
import com.ruoyi.carShop.mapper.BusinessStatisticsMapper;
import com.ruoyi.carShop.service.BusinessStatisticsService;
import com.ruoyi.system.api.domain.OrderDetails;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * 订单统计Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-09-07
 */
@Service
public class BusinessStatisticsServiceImpl implements BusinessStatisticsService
{
    @Autowired
    private BusinessStatisticsMapper businessStatisticsMapper;


    @Override
    public Statistics getCount(Statistics statistics) {
        return businessStatisticsMapper.getCount(statistics);
    }

    @Override
    public List<Statistics> getCountByType(Statistics statistics) {
        return businessStatisticsMapper.getCountByType(statistics);
    }

    @Override
    public BigDecimal getShopBalance(Long shopId) {
        return businessStatisticsMapper.getShopBalance(shopId);
    }

    @Override
    public BigDecimal getShopOrderIncome(Long shopId) {
        return businessStatisticsMapper.getShopOrderIncome(shopId);
    }

    @Override
    public BigDecimal getShopWithdrawal(Long shopId) {
        return businessStatisticsMapper.getShopWithdrawal(shopId);
    }

    @Override
    public List<OrderDetails> getTheShopOrder(Long shopId) {
        return businessStatisticsMapper.getTheShopOrder(shopId);
    }

    @Override
    public List<Withdrawal> getWithdrawalList(Long shopId) {
        return businessStatisticsMapper.getWithdrawalList(shopId);
    }

    @Override
    public Long addWithdrawal(Withdrawal withdrawal) {
        Long num = businessStatisticsMapper.addWithdrawal(withdrawal);
        Long num2 = 0L;
        if(num != 0){
            num2 = businessStatisticsMapper.updateShopBalance(withdrawal.getMerchantId(),withdrawal.getCurrentBalance());
        }
        return num2 != 0 ? num2 : 0;
    }
}
